<?php $numProducts = 2; ?>
<?php $productCount = $this->products->count(); ?>
<?php if($productCount > 0): ?>
	<div id="header-basket-lastadded">
		<div class="head">
			<div class="head-text">
				Warenkorb<br /><?php echo $this->productCount ?> Artikel
			</div>
		</div>
		<div class="inner-container">
			<div class="title">
				<div id="header-basket-recently-added-closelink"><a href="#"><img src="sherpa/img/btn-fenster-schliessen-x.gif" alt="Schliessen" /></a></div>
				<h2>Zuletzt hinzugefügt</h2>
			</div>
			<table cellspacing="0" class="items">
				<?php foreach($this->products AS $i => $product): ?>
					<?php $productId = $product->getProductId() ?>
					<tr class="data <?php echo (($i == $productCount - 1) || ($i == $numProducts)) ? ' last' : '' ?>">
						<td class="image" style="width:80px;text-align:center">
							<?php if($imageFilename = $product->getImageFilename()): ?>
								<img src="<?php echo $this->productImagePath('m') ?><?php echo $imageFilename ?>" alt="" width="60" />
							<?php else: ?>
								Kein Bild
							<?php endif; ?>
						</td>
						<td class="info">
							<b><?php echo $product->getFullProductName() ?></b><br />
							Stückpreis: <?php echo $this->config('currencyCode') ?> <?php echo $this->price($product->getPrice()) ?><br />
							Gr&ouml;sse: <?php echo $product->getSize() ?><br />
							Farbe: <?php echo $this->cartProductColors($product->getColorApplication()->getColors()) ?><br />
							Anzahl: <?php echo $product->getQuantity() ?><br />
							<a class="header-basket-lastadded-removelink" href="<?php echo $this->BaseUrl() . 'sherpa/api/cart/remove/?productId='. $productId ?>">entfernen</a>
						</td>
					</tr>
					<?php if($i >= $numProducts) break; ?>
				<?php endforeach; ?>
			</table>
			<table cellspacing="0" class="footer">
				<tr class="subtotal">
					<td>Zwischentotal Einkauf</td>
					<td style="text-align:right"><span class="currency"><?php echo $this->config('currencyCode') ?></span> <?php echo $this->price($this->products->calculateSubtotal()) ?></td>
				</tr>
                <?php echo $this->hook('Sherpa/View/Basket/LastAdded/Subtotal') ?>
				<tr class="links">
					<td style="vertical-align:bottom">Warenkorb <?php echo $this->productCount ?> Artikel</td>
					<td style="text-align:right"><a href="<?php echo $this->urlToPage($this->config('pageIdCart')) ?>"><img src="sherpa/img/btn-checkout.gif" alt="Checkout" /></a></td>
				</tr>
			</table>
		</div>
	</div>
	<script type="text/javascript">
	    //<![CDATA[
	    $(document).ready(function() {

	    	// Schliesst das Basket-"Popup"
			$('#header-basket-recently-added-closelink a').click(function() {
				$('#header-basket-recently-added').css('display', 'none');
				$('body #content').unbind('click');
				return false;
			});

			$('body #content').click(function() {
				$('#header-basket-recently-added').css('display', 'none');
				$('body #content').unbind('click');
				return false;
			});

			// Löscht ein Produkt aus dem Warenkorb
			$('.header-basket-lastadded-removelink').click(function() {
				var removeUrl = $(this).attr('href');
				$.get(removeUrl, function(data) {
					refreshCart();
				});
				return false;
			});

		});
	    //]]>
	</script>
<?php endif; ?>